Skip to main content

Full text of "VIC Stat (1982)(Commodore)"

See other formats


r*-"*"" 











This piece of software is 

developed by 

Datatronic AB, Stockholm 

Sweden 



VIC-STATISTIC-CASSETTE 

The VIC-S is a programmable 'read only memory' that consists of 
assembler codes, which simplify your work with statistics and graphic 
displays. The VIC-S will add approx. 15 commands to your basic language. 
For example, bar chart (histogram) horizontally or vertically, plotting with 
2024 points, printout of what is on the screen even if the screen is in graphic 
mode, statistical commands for calculations of, for example, mean value, 
standard deviation, variance, etc, etc. 



INSTALLATION 

(1) Switch off your VIC. 

(2) Place the VIC-S cassette in the appropriate slot 

(3) Add, if necessary, extra cassettes for instance RAM-xxK or PRO- 
GRAMMER'S AID. 

(4) Check that all the cassettes are properly positioned. 

Now you can switch on the power. 

If everything is correct, your VIC should start by displaying one 
demonstration program. 

If this is not the case, switch off your VIC. Check that the cassettes are 
properly installed. Also make sure that the extra RAM memory is not using 
the following addresses Hex:A000-BFFF DEC:40960-49151 . Even extra 
cassettes such as SUPER EXPANDER might use the same address area. The 
S. -cassette cannot be used with these accessories. 

Telephone your local VIC-dealer for information. 



STARTING THE V1C-S. CASSETTE 

This also checks that the S-CASSETTE is properly installed. 
In the demonstration program you will find these instructions: 

Fl = BASIC + STAT. 

F3 = BASIC 

Fl means the key marked "Fl". By pressing this key the demonstration 
program will be stopped and your VIC is ready for programming. 

The S-CASSETTE is activated and awaits commands. 

The key "F3" has the same function as Fl except in activating the S- 
CASSETTE. This means that statistical commands for the S-CASSETTE when 
used in your program will give you a SYNTAX ERROR reply. 

The S-CASSETTE can be started manually by typing the following: 
SYS 41035 and pressing the <RETURN> key. 

If everything is correct, the lowercase (small letters) should now be in 
uppercase (capital letters) while the uppercase should now produce 
graphic characters. This is VIC in its GRAPHIC MODE. The reason for this is 
that the graphic diagrams and histograms or bar-chart that you will be 
displaying should look as they normally do on paper. You can also use the 
other mode i.e. the TEXT MODE. Do try out these two modes yourself. 

The above mentioned can be tested by typing: 

PRINT CHR$(142) <RETURN>. 

To return to TEXT MODE by typing: 

PRINT CHR$(14)<RETURN>. 

Please note that the above two commands can be used whenever you want 

to. 

For example, 

10 PRINT CHR$(142): rem GRAPHIC MODE 

20 @SCALE,3,5 : rem print a scale 

30 PRINT CHR$(14) : rem back to TEXT MODE 



COMMANDS IN GENERAL 

In order not to make the normal basic routines slower, a control of special 
characters has been added. It tests to see whether the first character in a 
command has the special character "@". 

All the commands can be used as a direct command (without line numbers) 
or in a program (with line numbers). 

NOTE! Eleven variables are used by the S-circuit. They are: MV, SA, VA, 
NP, LK, SK, KK, BA, KO, Ml, MA. 

Do not use these variables other than as described in the manual as long as 
the S-CASSETTE is in use. 

All commands have input checks for proper input. That is to say that if the 
input value is higher than normal a reply of "ILLEGAL QUANTITY ERROR." 
will be seen on the screen. 

A syntax control of all commands is of course included. If you make a 
spelling mistake the VIC will reply "SYNTAX ERROR." 

If you, for example, get "DIVISION BY ZERO ERROR IN 20" and line 20 is 
20 @ LINREG,A,223, please check your input data (matrix) for the wrong 
value. 

As described earlier in using the command a fixed value is given XXX,5,8. 
This can be replaced by a variable name such as XXX, a, b, and so on. 

Ex: 10 FORT=l to 10 
20 @PLOT,T,5 
30 NEXT T 

This will give you a horizontally straight line 5 steps from the top row. 
A good idea is to use the normal variables x and y. 

ex. 20 @PLOT,x,y. 

A best way of using this aid is by: 

(1) loading data into a matrix. Ex.( A(l)-A(max) ). 

(2) doing calculation (with or without S-CMD's). 

(3) adjusting the results to the acceptable levels for the circuit. 

(4) having printouts or graphic displays on your printer. 



COMMANDS 

KILL Maybe not the best command to start with, anyhow its function 

is to restore the VIC to its original status i.e. as before the S- 
circuit was activated. This command will not erase any program 
which you might have stored in your VIC. 
Syntax: @KILL 

PLOT- (a)/(b)/(k) 

All plotting commands test that the actual point desired is on 
the screen before plotting. This means that if there is any text on 
the screen, it won't be written over (only plot symbols). At this 
point all plot symbols are prevented from being written on to its 
actual position. 

PLOT This will help you to plot and draw graphs on the VIC screen, the 

screen now contains 2024 points (44*46). 
Syntax: @PLOT,x,y X=0-43 Y=0-45 

PLOTD This command will be switch of a specified point on the screen. 
" Syntax: @PLOTD,x,y X=0-43 Y=0-45 
Note! D="DELETE" 

PLOTC The command tests if a specific point on the VIC screen is on or 
off. Syntax: @PLOTC,x,y X=0-43 Y=0-45 
You can get the answer by typing peek(828)= 
(l)=on ,(0)=off 
Note! C="CHECK" 

PAPER This command copies what is on the screen of your VIC (either 
bars, plots or just ordinary text)on to the paper of your VIC-1 51 5 
printer. SYNTAX: ©PAPER, TR, BR, LC, RC 



Whe 



:TR 

BR 

LC 

RC 



= Top-row 
= Bottom-row 
= Left-coloum 
= Right-coloum 



(start) 
(stop) 



1-24 
24-0 
0-23 
23-0 



With this command you can control the type of printouts 
that you want, the whole screen or just a specified part of 
the screen. 

If you wish to copy everything on the screen and not only 
a part of it, just write: 

@PAPER This will copy the whole screen on to the paper. 

If you wish to add comments to the graphic picture, use the 
programmable-cursor positioner. 

Ex. print cursor home (Given start position) 
print cursor down ( no. of times down) 
print cursor right ( no. of times right) 
print "TEXT " 

This can be done in one string 
(see examples on the last page). 



BARCHART 



BARV 



BARH 



SCALE 



When the bar command is given, only one bar will be printed 
either horizontally or vertically. If you wish to add more bars to 
the same bar-chart, repeat the command with the new position 
and data. You can put bars in whatever order you want and 
wherever you like. It is possible to add bars, place them next to 
each other etc, etc. When giving the bar-command a scale will 
be drawn. If no scale has been given, the scale will have the 
value 5,5 i.e. every mark has the value of 1 . More about scales 
later. 

Means BAR-CHART VERTICALLY (bottom to top). Here you must 
specify three variables. SYNTAX: @BARV,A,B,C 

Where:A = START POS. 



B 

C 



STOP POS. 
HIGHT 



0-20 
0-20 
0-21 



Ex. @BARH,0,5,8 

As above except that it will be printed horizontally (left to right). 
Here you have to specify only two variables. Note! the length of 
the bars can be much longer but the width of the bars cannot be 
varied as in BARV. 
SYNTAX @BARV,A,B 

Where:A = ROW 0—17 (Start at home.) 

B = LENGTH 0—19 (Length or hight) 

Ex. @BARV,1,20 

This command gives you an indexed L-shaped scale in column 
and row 22. Its default value = 5, i.e. every mark on the scale is 
equal to one. This command is also useful with plotting routines. 
SYNTAX: @SCALE,H,V 

Where:H = Index on the horizontal scale — 16 



V = Index on the vertical scale 



0-12 



Ex. If the index value is 10, on every fifth mark the values 10,20, 
30,40,50,60,70,80 etc, etc will be written. 

Ex. ©SCALE, 0,5 This gives only a vertical scale. 

COLR With this command you have the possibility of steering the 

graphic display, boarder and the background colours. 
SYNTAX: @COLR,G @COLR,G,S or @COLR,G,S,T 
Where G = colour of the graphic display: scales, bars, plot 
points, etc, etc. Note! Doesn't change the colour of the text. 

G = — 7 (VIC's 8 primary colours) see last page. 

S = Screen colours 8 — 255 (Background + boarder colours). 
This value does not have to be given every time a colour 
is chosen, only when a new colour on the boarder or the 
background is required. All colours are found on the 
last page. 

T = Text colour — 7. Does not have to be given at every 
colour command. 



COMMANDS FOR STATISTICS 

To use these commands a matrix is built up in the VIC's working 
storage area. And because of this the matrix has to be dimen- 
sioned. 

Note! The matrix should be dimensioned to fit at least the 
amount of data that you will be working with. The name of the 
matrix MUST be a one character name e.g. 'A' and not 'AB'. X(0) 
is not used in stat-commands. Statistics can be calculated in the 
two different ways: in grouped or ungrouped. Ungrouped data 
are put in no special order in the matrix, while grouped data are 
put in sequential order. 

Example SI PERSON: David John Bill Peter Adam Edward 

GROUPED LENGTH: 
DATA HEIGHT: 

QUA or Quantity in this case will be 12. 

Mean value Standard deviation Variance. 

(a) Population = STATP,X,Quantity. 

(b) Sample = STATS,X,Quantity. 

SYNTAX: Ex. @STATP,A,25 

This means calculation according to the population-method of 
matrix A(1) to A(25). 

The answers to these calculations are given in the variables MV, 
VA, SA. 



A(l) 


A(3) 


A(5) 


A(7) 


A(9) 


A(ll) 


A(2) 


A(4) 


A(6) 


A(8) 


A(10) 


A(12) 



STAT 



Where: MV 
VA 
SA 



Meanvalue 
Variance 
Standard deviation 



EX. 



10 DIM A(10) 

20 FORX=lTO10 

30 INPUT"data";D 

40 NEXTx 

50 @STATP,A,10 

60 PRINT "meanvalue 

= ";MV 

70 PRINT "standard deviation 

80 PRINT "variance= ";VA 

90 REM ev. diagram ??? 

Please note that the variables MV, SA, VA should not be used when 
statistical commands are intended for the program you are writing. 



rem reservers place for 1 bytes 
rem Note! Starting at A(l) 
rem fetch data . . . 

rem calculating stat. 

rem printing of the results 
;SA 



REGRESSION/CORRELATION/MINMAX/SORTING 



LINREG LINEAR-REGRESSION can be calculated by using a one dimen- 
sion matrix. Syntax @LINREG,X,QUA. 

Note! Grouped data see example SI on page 6. QUA in that 
case will be 12. 
Where X = matrix name 
QUA. = amount of data to be calculated in the matrix 

Ex. @LINREG,A,123 

The answer will be given in the following variables NP, LK, SK, 
KK,BA. 

NP = Zero point 

LK = Gradient coefficient 

SK = Coefficient of determination 

KK = Coefficient of correlation 

BA = Standard error of estimate 

LINKO LINEAR-CORRELATION can be calculated by using a one 
dimension matrix. Syntax@LINKO,X,QUA. 
Note! Grouped data see example SI on page 6. 
Here like the one above X = Matrix name, 
and QUANTITY = amount of data to be calculated. 
Ex. @LINKO,A,456 

The answer will be given in the variable KO (linear-correlation). 

MINMAX This command is used when you want either the LOWEST or the 
HIGHEST values of a one dimension matrix. 
Syntax: @MlNMAX,X,Max-QUA. 
Note! The command sorts your matrix in increasing sequense. 

Ex. @MINMAX,A,135 

The answer will be given in the variables Ml and MA. 

Ml =MIN value 
MA = MAX value 

SO Sorting of data in a matrix in increasing number sequence. The 

matrix must be dimensioned before a routine can call on the 
matrix. The most suitable approach would be to sort the matrix 
in the beginning of the program. 

If more than one matrix are dimensioned in your program the 
only one to be sorted is the first dimensioned. 
Sort X(l )— X(max). Syntax: @SO,QUA. 

QUANTITY = Max amount. 

NOTE!! EVEN STRINGS CAN BE SORTED IN ALPHABETICAL 
ORDER. 

GROUP GROUP CLASSIFICATION can easily be arranged by using a 
FOR/NEXT loop after sorting. The FOR/NEXT loop will take out 
every tenth value from the matrix. 

Ex 10 DIMA(IOO) 

20 @SO,A 

30 FORX = 1 TO 100 STEP 10 
40 PRINT A(X) 
50 NEXTX 



rem dimensioning 
rem sorting 
rem fetch every 1 0th 
rem write every 1 0th 



To calculate a straight line to a given set of coordinates using 
the method of least squares, here is an example. 
The table below shows the height and weight of 1 1 male 
students. We will now find out what a normal student should 
weigh if his height is between: 70 — 72 ins. 



Table 

(X) Height 
(in.) 
(Y) Weight 
(lbs 





1 


2 


3 


4 


5 


6 


7 


8 


9 


10 


11 


t 


71 


73 


64 


65 


61 


70 


65 


72 


63 


67 


64 


) 
t 


160 


183 


154 


168 


159 


180 


145 


210 


132 


168 


141 



The curve can be expressed by the function F(X)= NP + (LK * X) 

Program example: 

5 REM input of data 
10 DIM A (25) 
20 FOR N = 1 TO 22 
30 READ B : A(N)= B 
40 NEXT N 

50 REM calculating the curve 
60 @LINREG,A,22 :REM 2*11=22 

70 PRINT"F(X)=";NP;"+(";LK;"*X)" 

80 PRINT"Coefficient of determination=";SK 
90 PRINT"Coefficient of correlation=";KK 

100 PRINT"Standard error of estimate=";BA 

110 PRINT 

120 REM person example 

130 INPUT "X= " ; X 

140 Y=NP+LK*X :REM interpolation 

150 PRINT"Y= ";Y 

160 GOTO 130 

170 REP data. NOTE! THE DATA SEQUENCE 

300 DATA 71 ,1 60,73,1 83,64,1 54,65,1 68 

310 DATA 61 ,1 59,70,1 80,65,1 45,72,21 

320 DATA 63,132,67,168,64,141 



RUN 

F(X)=-1 06.791 74+(4.04722332*X) 
Coefficient of determinations 556260344 
Coefficient of correlation^. 745828629 
Standard error of estimate=l 5.41 34848 
X =? 70 

Y = 176.513892 
X =? 72 

Y = 184.608339 



PROGRAM EXAMPLE 

10 DIM A(15): PRINT CHR$(1 47) 

20 PRINT "collecting dafa" 

30 INPUT "How much data shall be 

saved? ";MAX 

40 FOR X = 1 TO MAX 

50 INPUT"data: ";DA 

60 A(X)=DA 

70 NEXTX: PRINT CHR $(147) 

80 PRINT "all data has been saved" 

90 : 

1 00 @SO ,A,MAX 

1 10 FOR X = 1 TO MAX : PRINT A(X) 

:NEXT X 

120: 

130 @MINMAX,A,MAX :PRINT"min- 

data= ";MI 

140 PRINT"max-data= ";MX 

150 @STATP,A,MAX : PRINT'mean 

value= ";MV 

160 PRINT"standard devation= ";SA 

170 PRINT"variance= ";VA 

180 FOR X= 1 TO2500:NEXTX 

190 REM *** graphic *** 

200 A=5 : B=9 : F=25 

210@COLR,0,F 
220@BARV,1,2,A 
230 @COLR,2 
240 @BARV,3,4,B 
END 



Comments: 

clear the screen 
write title. 

type in max amount of input 
loop for input, 
accept data until a(x). 
save data in matrix "a" 
max data - clear screen 



command for sorting 

write out the whole matrix "a" 



command for min & max. 
write out the result of max 

command for statistics p. 
write the result, 
write the result, 
"wait" loop 

determine the bar height & 

colour 

graphic=black colour=25 

bar l=black. 

graphic=red 

bar 2=red. 



TEXT ON GRAPHIC PICTURES: 

10@BARV,1,2,5 

20@BARV,10,11,10 

30 PRINT"SQQQQQQQQQQQQ 

QQQ)) YOURS" 

40 PRINT"SQQQQQQQQQQ]]]]]]]]]]] 

MINE" 

50 GET AS : IF A$= " "THEN 100 

60 END 

Example: "SQQQQQQQQQQ]]]]]] text" 
S=CRSR HOME (the given starting place) 
Q=CRSR DOWN 
1=CRSR RIGHT 



:REM CREATE 2 BARS 



: REM YOURS=TEXT FOR BAR 1 

: REM MINE=TEXT FOR BAR 2 
:REM wait loop. 



COLOUR COMMAND 

DATA FOR COLOUR COMMAND @COLR,GJ,S 
S=VALUE (SCREEN) 









(BOARDER) 










(SCREEN) 


BLACK 


WHITE 


RED 


CYAN 


VIOLET 


GREEN 


BLUE 


YELLOW 


black 


8 


9 


10 


11 


12 


13 


14 


15 


white 


24 


25 


26 


27 


28 


29 


30 


31 


red 


40 


41 


42 


43 


44 


45 


46 


47 


cyan 


56 


57 


58 


59 


60 


61 


62 


63 


violet 


72 


73 


74 


75 


76 


77 


78 


79 


green 


88 


89 


90 


91 


92 


93 


94 


95 


blue 


104 


105 


106 


107 


107 


109 


110 


111 


yellow 


120 


121 


122 


123 


124 


125 


126 


127 


orange 


136 


137 


138 


139 


140 


141 


142 


143 


light 
orange 


152 


153 


154 


155 


156 


157 


158 


159 


pink 


168 


169 


170 


171 


172 


173 


174 


175 


light cyan 


184 


185 


186 


187 


188 


189 


190 


191 


light violet 


200 


201 


202 


203 


204 


205 


206 


207 


light 

green 


216 


217 


218 


219 


220 


221 


222 


223 


light blue 


232 


233 


234 


235 


236 


237 


238 


239 


light 
yellow 


248 


249 


250 


251 


252 


253 


254 


255 


G-VALUE (GRAPHIC) / T-VALUE (TEXT) 














= BLACK 


















1 = WHITE 


















2 = RED 


















3 = CYAN 


















4 = VIOLET 


















5 = GREEN 


















6 = BLUE 


















7 = GUL 



















10 






.•• 








Cm. commodore 

^COMPUTER 



■datatr 



Made in Sweden by 
atronic ab, Box 42054, S-126 12 Stockholm